from flask import Flask
from config import config
from db import db
# 这就话的作用是把表的结构引入
from model import LoggerEvent


def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    with app.app_context():
        db.init_app(app)
        db.create_all()
    config[config_name].init_app(app)
    print("注册蓝图")
    from .api_1_0 import api as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0')
    return app

